<?php

class ContactController extends Controller {

    public $activeMemu = "contact";

    public function actionIndex() {
        if($this->validate()){
            $email = Yii::app()->params['sendEmail'];
            $subject = 'Mail from Lx Web';
            $name = $_POST['name'];
            
            $message = "From : ".$_POST['name']."\n".
                       "E-mail :".$_POST['email']."\n \n".
                       "".$_POST['message'];

            mail($email, $subject, $message);
        }

        $this->render('index');
    }

    private function validate(){
        if($_POST['name'] == ''){
            return false;
        }
        if($_POST['email'] == ''){
            return false;
        }
        if($_POST['message'] == ''){
            return false;
        }
        return ture;
    }
    // Uncomment the following methods and override them if needed
    /*
      public function filters()
      {
      // return the filter configuration for this controller, e.g.:
      return array(
      'inlineFilterName',
      array(
      'class'=>'path.to.FilterClass',
      'propertyName'=>'propertyValue',
      ),
      );
      }

      public function actions()
      {
      // return external action classes, e.g.:
      return array(
      'action1'=>'path.to.ActionClass',
      'action2'=>array(
      'class'=>'path.to.AnotherActionClass',
      'propertyName'=>'propertyValue',
      ),
      );
      }
     */
}